{% extends extend_template %}
{%block center%}
{% include "transsys/addPromoterModal.html" %}
{% load ts_extras%}
<div id="main" class="edit_form" >
    <h2>Edit gene</h2>
    <form action="edit" id="editGene" method="post" class="edit">
        {% csrf_token %}
        <div class="input_field" >
            <label>Name:</label>
            <span class="helptext">Enter name of gene</span>
            <input type="text" name="name" value="{{gene.name}}"/>
        </div>
        <div class="input_field" >
            <label>Product:</label>
            <span class="helptext">Choose the factor encoding gene</span>
            <select name="product">
                {% for f in request.session.ts_program.tp.factor_list %}
                <option value="{{f.name}}"
                        {% if gene.product.name == f.name %}
                        selected="selected"
                        {%endif%}
                        >{{f.name}}</option>
                {% endfor %}
            </select>
        </div>
        <div id="promoters" class="input_field">
            <label>Promoters:</label>
            <span class="helptext">Specifying the promoters which regulate this gene</span>
            <a href="#promoter_form" class="link-button" id="addPromoter">Add Promoter</a>
            <ul id="promoter_list">
                {% for p in promoter_list %}
                {% if p.type == "constitutive" %}
                <li id='{{p.id}}' class="{{p.css}}">
                    <div class="promoter_element" >
                        <label>Type:</label>
                        <b>{{p.type}}</b>
                        <input type="hidden" name="ptype" value="{{p.type}}" readonly="readonly"/>
                        <label>Expression:</label>
                        <input type="text" name="pexpr" value="{{p.expr}}"
                            {% if not p.expr|isEditable %}
                                readonly="readonly"
                                title="Unable to edit this expression in this form! Choose Code Transsys program instead."
                            {% endif %}/>
                        <input type="hidden" name="pfactor" value="undefined"/>
                        <input type="hidden" name="pexpr1" value="undefined"/>
                        <input type="hidden" name="pexpr2" value="undefined"/>
                        <a href="javascript:void(0);" class="del" id="{{p.del_id}}"></a>
                    </div>
                </li>
                {% else %}
                <li id="{{p.id}}" class="{{p.css}}">
                    <div class="promoter_element" >
                        <label>Type:</label>
                        <b>{{p.type}}</b>
                        <input type="hidden" name="ptype" value="{{p.type}}" readonly="readonly"/>
                        <label>Factor:</label>
                        <select name="pfactor">
                            {% for f in request.session.ts_program.tp.factor_list %}
                            <option value="{{f.name}}"
                                    {% if f in p.factor_list %}
                                    selected="selected"
                                    {%endif%}
                                    >{{f.name}}</option>
                            {% endfor %}
                        </select>
                        <label>Expression 1:</label>
                        <input type="text" name="pexpr1" value="{{p.expr1}}"
                            {% if not p.expr1|isEditable %}
                                readonly="readonly"
                                title="Unable to edit this expression in this form! Choose Code Transsys program instead."
                            {% endif %}/>
                        <label>Expression 2:</label>
                        <input type="text" name="pexpr2" value="{{p.expr2}}"
                            {% if not p.expr2|isEditable %}
                                readonly="readonly"
                                title="Unable to edit this expression in this form! Choose Code Transsys program instead."
                            {% endif %}/>
                        <input type="hidden" name="pexpr" value="undefined"/>
                        <a href="javascript:void(0);" class="del" id="{{p.del_id}}"></a>
                    </div>
                </li>
                {% endif %}
                {% endfor %}
            </ul>
            {% comment %} Trick with_sgx parameter {% endcomment %}
            {% if extend_template == "simgenex/base_simgenex.html" %}
                <input type="hidden" name="with_sgx" value="1"/>
            {% endif %}
        </div>
        <div>
            <button type="submit" name="submit" > Submit</button>
            <button type="submit" name="delete" > Delete</button>
        </div>
    </form>

</div>
{% endblock %}